package com.gkym.es.config;

import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * [ Es配置文件 ]
 *
 * @author Love丶TG
 * @version 1.0.0
 * @create 2020 年 01 月 14 日 16:08
 */
//@Configuration
public class EsConfig {

//    @Bean
//    TransportClient transportClient() throws UnknownHostException {
//        Settings settings = Settings.builder()
//                .put("cluster.name", "GKYM_ES")
//                .build();
//        TransportClient client = new PreBuiltTransportClient(settings);
//        client.addTransportAddress(new TransportAddress(InetAddress.getByName("127.0.0.1")
//                , 9200));
//        return client;
//    }

    /// RestHighLevelClient的使用
//    @Bean
//    RestHighLevelClient elasticsearchClient() {
//        ClientConfiguration configuration = ClientConfiguration.builder()
//                .connectedTo("localhost:9200")
//                .build();
//        RestHighLevelClient client = RestClients.create(configuration).rest();
//        return client;
//    }

}
